package cn.edu.xjtu.daily.April.day_4_15;

import java.util.Scanner;

/**
 * @author Hydrion-QLz
 * @date 2022-04-15 9:20
 * @description P4715 【深基16.例1】淘汰赛 https://www.luogu.com.cn/problem/P4715
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num = (int) Math.pow(2, n);
        // 读取输入
        Node[][] score = new Node[n + 1][num];
        for (int i = 0; i < num; i++) {
            int ability = sc.nextInt();
            score[0][i] = new Node(i + 1, ability);
        }

        // 数据处理
        for (int i = 1; i < n; i++) {
            int idx = 0;
            int end = (int) Math.pow(2, n - i + 1);
            for (int j = 0; j < end; j += 2) {
                // 获得晋级结点
                score[i][idx] = getMax(score[i - 1][j], score[i - 1][j + 1]);
                // 继续看下一组
                idx++;
            }
        }
        System.out.println(score[n - 1][1].ability > score[n - 1][0].ability ? score[n - 1][0].number : score[n - 1][1].number);
    }

    /**
     * 获得两个结点中晋级的结点
     *
     * @param node1
     * @param node2
     * @return
     */
    private static Node getMax(Node node1, Node node2) {
        return node1.ability > node2.ability ? node1 : node2;
    }
}

class Node {
    int number;
    int ability;

    public Node(int number, int ability) {
        this.number = number;
        this.ability = ability;
    }
}
